<template>
  <div>
    <van-nav-bar left-arrow title="选择客户" @click-left="$router.go(-1)">
      <template #right>
        <van-icon name="wap-home-o" size="24" />
      </template>
    </van-nav-bar>
    <van-search
      v-model="value"
      shape="round"
      placeholder="客户名称/联系方式"
      show-action
      @search="onSearch"
    >
      <template #action>
        <div @click="onSearch">搜索</div>
      </template>
    </van-search>
    <div>
      <van-cell :title="item.custName" is-link :icon="header" v-for="item in listData" :key="item.id" @click="govisit(item.id,item.custName)"/>
    </div>
  </div>
</template>

<script>
import {GetCustListData} from "../request/api"
export default {
  data() {
    return {
      value: "",
      listData:[],
      header: require("../assets/img/头像男 拷贝 4.png"),
    };
  },
  methods: {
    onSearch(val) {
      console.log(val);
    },
    govisit(val,custname){
        this.$router.push({path:"/newaddvisit",query:{id:val,custname:custname}})
    }
  },
  created(){
      GetCustListData(
          {keyword:this.value,current:"1",size:"32"}
      ).then(res=>{
          console.log(res);
          this.listData = res.data.records
      })
  }
};
</script>
 
<style lang = "less" scoped>
.van-nav-bar {
  background-color: rgb(6, 6, 139);
  /deep/.van-nav-bar__title,
  /deep/.van-icon {
    color: #fff;
  }
  /deep/.van-nav-bar__text {
    color: #fff;
  }
}
</style>